//------------------------------------------------
//		ADC.c
//	ADC library
//	Arthur Benemann 02/04/2012
//------------------------------------------------
//	Description:
//  Functions to initialize and read the ADC module.
//  Currently only works with pin AN0 // FIXME
//-----------------------------------------------
//	Requeriments:
//	ADC module
//	1 analog pin
//-----------------------------------------------

#include "ADC/ADC.h"
#include "picDev.h"

//-----------------Public Functions ------------------------------
	
void initADC(void) {
    // Config inputs
    AD1CHS = 0;         // Input to AN0 // FIXME
    // Config ADC module
    AD1CON1 = 0x80E4;   // ADC on, Integer, auto sample start, auto-convert
    AD1CON2 = 0x0000;   // AVdd, AVss, MUXA only
    AD1CON3 = 0x1003;   // 16 Tad auto-sample, Tad = 3*Tcy
}

unsigned int readADC(unsigned char channel){
    return ADC1BUF0;
}


